package com.yoomiito.app.ui.order.list

import android.view.View
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yoomiito.app.R
import com.yoomiito.app.model.bean.OrderInfo
import com.yoomiito.app.utils.ImageLoader
import com.yoomiito.app.widget.CouponView
import com.yoomiito.app.widget.RoundImageView

/**
 * 我的订单--京东订单样式
 */
class JDOrderAdapter :BaseQuickAdapter<OrderInfo,BaseViewHolder>(R.layout.item_order_1,null){

    override fun convert(helper: BaseViewHolder?, item: OrderInfo?) {
        helper?.getView<ImageView>(R.id.goodsFlag)?.setImageResource(R.drawable.icon_jd)
        helper?.setText(R.id.orderNum,"订单：${item?.id}")
        helper?.getView<RoundImageView>(R.id.goodsPic).let {
            ImageLoader.getInstance().into(mContext,item?.item_picture,it)
        }
        helper?.setText(R.id.goodsTitle,item?.item_title)
        helper?.setGone(R.id.couponView,false)
        helper?.getView<CouponView>(R.id.awardView)?.setText(item?.user_income!!)
        helper?.setText(R.id.orderDate,item?.ctime)
        helper?.setText(R.id.orderPrice,item?.price)
        helper?.setGone(R.id.statusBg,5 == item?.status)

        helper?.getView<ImageView>(R.id.statusIv)?.setImageResource(
                when(item?.status){
                    5 -> {
                        R.mipmap.failure
                    }
                    else->{
                        0
                    }
                }
        )
    }

}